<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title></title>
	<link rel="stylesheet" type="text/css" href="../../css/reset.css"/>
	<link rel="stylesheet" type="text/css" href="../../css/add.css"/>
</head>
<body>
<div id="app">
	<div class="header">
		<span>修改用户信息</span>
	</div>
	<div class="content">
		<table>
			<tr>
				<td class="text-right">手机号码</td><td class="content_right"><input id="phone" class="input inline-input" placeholder="请输入手机号码"> <span id="find" class="btn btn-info">立即查找</span></td>
			</tr>
		</table>
	</div>


	<div class="header">
		<span>查找信息如下</span>
	</div>
	<div class="content">
		<table>
			<tr>
				<td class="text-right">姓名</td><td class="content_right"><input class="input" placeholder="请输入姓名" id="editName"></td>
			</tr>
			<tr>
				<td class="text-right">手机号码</td><td class="content_right"><input onblur="isPhoneNum()" class="input" placeholder="请输入手机号码" id="editPhone"></td>
			</tr>
			<tr>
				<td class="text-right">密码</td><td class="content_right"><input class="input" placeholder="请输入密码" id="editPassword"></td>
			</tr>
			<tr>
				<td></td><td class="content_right"><span class="btn btn-info" id="update">立即修改</span> <span class="btn">重置</span> </td>
			</tr>
		</table>
	</div>
</div>
</body>

<script src="/qrcode/jquery2.1.4.js"></script>
<script src="/layer/layer.js"></script>
<script>
	$(".header:eq(1),.content:eq(1)").hide();
	var userId = null;
	var editName = null;
	var editPhone = null;
	var editPassword = null;


	$(function () {
		$("#find").click(function () {
			var windowId = layer.load();
			var phone = $("#phone").val();
			$.getJSON("/user/find.do",{phone:phone},function (data) {
				layer.close(windowId);
				layer.alert(data.result);
				// 查找到对应单号的快递
				if (data.status == 0){
					// 1秒渐渐显示快递具体信息
					$(".header:eq(1),.content:eq(1)").fadeIn(1000);
					// {"result":"查询成功",
					// "data":{"id":1,"number":"SF1111","username":"张三","userPhone":"15312341234","company":"顺丰速递","inTime":"Jul 29, 2021, 11:42:56 AM","outTime":"Jul 29, 2021, 11:42:56 AM","sysPhone":"18856334567","status":1},
					// "status":0}
					userId = data.data.id;

					$("input:eq(1)").val(data.data.name);
					$("input:eq(2)").val(data.data.phone);
					$("input:eq(3)").val(data.data.password);


					// 前面的查询结束，下面进行修改主体部分的操作
					$("#update").click(function () {
						var windowId = layer.load();
						editName = $("#editName").val();
						editPhone = $("#editPhone").val();
						editPassword = $("#editPassword").val();

						var courier = {
							userId:userId,
							editName:editName,
							editPhone:editPhone,
							editPassword:editPassword
						};

						$.getJSON("/user/update.do",courier,function (data) {
							// 关闭圈圈
							layer.close(windowId);
							layer.alert(data.result);

							if (data.status==0){
								// 修改成功
								// 修改成功就将快递具体信息隐藏起来
								$(".header:eq(1),.content:eq(1)").hide();
							};
						});


					});
				};
			});

		});
	});
</script>
<script>

	/*校验手机号*/
	function isPhoneNum() {
		// 如果因为现有的号码不能满足市场需求，电信服务商会增大号码范围。
		// 所以一般情况下只要验证手机号码为11位，且以1开头。
		var str = document.getElementById("editPhone").value;
		var reg = /^^1[0-9]{10}$$/;
		if (!reg.test(str)){
			layer.alert("请正确输入手机号！");
		}
		return reg.test(str);
	}

</script>

</html>




<!--
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="../../css/reset.css"/>
		<link rel="stylesheet" type="text/css" href="../../css/add.css"/>
	</head>
	<body>
		<div id="app">
			<div class="header">
				<span>修改快递员</span>
			</div>
			<div class="content">
				<table>	
					<tr>
						<td class="text-right">手机号码</td><td class="content_right"><input class="input inline-input" placeholder="请输入手机号码"> <span class="btn btn-info">立即查找</span></td>
					</tr>
				</table>
			</div>
			
			
			<div class="header">
				<span>查找信息如下</span>
			</div>
			<div class="content">
				<table>
					<tr>
						<td class="text-right">姓名</td><td class="content_right"><input class="input" placeholder="请输入姓名"></td>
					</tr>
					<tr>
						<td class="text-right">手机号码</td><td class="content_right"><input class="input" placeholder="请输入姓名"></td>
					</tr>
					<tr>
						<td class="text-right">身份证号码</td><td class="content_right"><input class="input" placeholder="请输入姓名"></td>
					</tr>
					<tr>
						<td class="text-right">密码</td><td class="content_right"><input class="input" placeholder="请输入姓名"></td>
					</tr>
					<tr>
						<td></td><td class="content_right"><span class="btn btn-info">立即修改</span> <span class="btn">重置</span> </td>
					</tr>
				</table>
			</div>
		</div>
	</body>
</html>
-->
